package server;

import Constans.Constants;
import bean.PhoneComm;
import bean.PhoneResult;
import com.alibaba.fastjson.JSONObject;
import request.HttpUtil;

import java.util.List;

/**
 * @author:zhengyilong
 * @email:1797344574@qq.com
 * @phone:13479394730
 * @desc:
 * @DateTime:2021/12/8 19:51
 **/
public class Phone {
    public static List<PhoneResult> getPhone(String phone){

        //拼接请求字符串，请求示例：http://apis.juhe.cn/mobile/get?phone=13429667914&key=您申请的KEY
        String url = Constants.PHONE_URL + "?phone=" + phone + "&key=" + Constants.PHONE_KEY;
        //使用自定义get方法发送请求，并接受响应
        String result = HttpUtil.get(url);

        PhoneComm phoneComm = JSONObject.parseObject(result, PhoneComm.class);
        return phoneComm.getResult();

    }
}

